<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SupplyNews extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
		$table  =  $this->table('supply_news',array('engine'=>'InnoDB','collation'=>'utf8_unicode_ci'));
        $table->addColumn('category_id', 'integer',array('limit' => 11,'comment'=>'分类ID'))
            ->addColumn('title', 'string',array('limit' => 255,'comment'=>'资讯标题')) 
            ->addColumn('summary', 'string',array('limit' => 200,'comment'=>'资讯摘要')) 
            ->addColumn('author', 'string',array('limit' => 50,'comment'=>'作者'))
            ->addColumn('image', 'string',array('limit' => 200,'comment'=>'图片链地址'))
            ->addColumn('content', 'text',array('comment'=>'资讯内容'))
            ->addColumn('sort', 'boolean',array('limit' => 99,'comment'=>'排序0~99'))
            ->addColumn('is_top', 'boolean',array('limit' => 1,'comment'=>'是否置顶'))
            ->addColumn('like', 'integer',array('limit' => 10,'comment'=>'喜欢'))
            ->addColumn('views', 'integer',array('limit' => 10,'comment'=>'浏览'))
            ->addColumn('comments', 'integer',array('limit' => 10,'comment'=>'评论数'))
			->addColumn('status', 'boolean',array('limit' => 1,'default'=>'1','comment'=>'状态'))
            ->addColumn('publish_time', 'integer',array('default'=>0,'comment'=>'发布时间'))
            ->addColumn('create_time', 'integer',array('default'=>0,'comment'=>'创建时间'))
            ->addColumn('update_time', 'integer',array('null'=>true,'comment'=>'更新时间'))
            ->addColumn('delete_time', 'integer',array('null'=>true,'comment'=>'删除时间'))
            ->addIndex(array('category_id'), array('unique'  =>  true))
            ->create();
    }
}
